//
//  LcRandom.m
//  18Birdies
//
//  Created by Lc on 15/4/9.
//  Copyright (c) 2015年 Lc. All rights reserved.
//

#import "LcPreconditions.h"
#import "LcRandom.h"

@implementation LcRandom

+ (int)random:(int)upperBound {
  return arc4random_uniform(upperBound);
}

+ (NSString*)randomDigits:(int)digit {
  LC_CHECK_TRUE(digit > 0 && digit < 10);
  int minValue = 1;
  while (digit > 1) {
    minValue *= 10;
    --digit;
  }
  int random = arc4random_uniform(minValue * 9) + minValue;
  return [NSString stringWithFormat:@"%d", random];
}

@end
